import { Component } from "react";
import './Header.css'
export default class Header extends Component {
  constructor(props) {
    super(props);
    this.state={
        infor:''
    }
  }
  add(e){
    // console.log(this.props);
    // console.log(e.target.value);
    this.setState({
        infor:e.target.value,
    })
  }
  addObj(e){
    // console.log(e.keyCode);
    if(e.keyCode===13){
        this.props.addObj(this.state.infor)
        this.setState({
            infor: '',
        })
    }
  }
  render() {
    return <input className="inp" value={this.state.infor} type="text" onInput={this.add.bind(this)} onKeyDown={this.addObj.bind(this)}></input>;
  }
}
